<!DOCTYPE html>
<html lang="en">
#parse('base/head.html')
<body class="no-skin">

<div class="main-container ace-save-state" id="main-container">
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <div class="row">

                    <div class="col-sm-12">
                        <div class="row col-md-12 fp-toolbar fpxmList">
                            <button onclick="detailClick_pro()" type="button" class="btn btn-sm btn-primary pull-left">
                                <span class="ace-icon fa fa-plus icon-on-right"></span>新增
                            </button>
                            <button onclick="deleteBySelectIds()" type="button"
                                    class="btn btn-sm btn-primary pull-left"><span
                                    class="ace-icon fa fa-trash icon-on-right"></span>删除
                            </button>
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <table id="grid-table"></table>
                                <table id="xxbs-list"></table>
                                <div id="xxbs-list-pager"></div>
                            </div>
                        </div>
                    </div>
                    <div/>
                </div>
            </div><!-- /.page-content -->
        </div>
    </div>
    #parse('base/footer.html')
    <script>
        var projectType = '';
        jQuery(function ($) {
            menuActive(2);
            $("#projectSearchBtn").on('click', function () {
                console.log("projectSearchBtn click");
                jQuery("#xxbs-list").jqGrid('setGridParam', {
                    datatype: 'json',
                    mtype: "POST",
                    postData: {
                        'projectName': $("#form-field-project-name").val(),
                        'projectType': $("#form-field-project-type  option:selected").val()
                    }, //发送数据
                    page: 1
                }).trigger("reloadGrid");
            });

        });
    </script>
    <!-- 信息报送列表 -->
    <script type="text/javascript">
        function reloadGridData() {
            console.log("reloadGridData...");
            jQuery("#xxbs-list").jqGrid('setGridParam', {
                datatype: 'json',
                mtype: "POST",
                postData: {
                    'projectName': $("#form-field-project-name").val(),
                    'projectType': $("#form-field-project-type  option:selected").val()
                }, //发送数据
                page: 1
            }).trigger("reloadGrid");
        }
        var parentBodyHeight = $('#left-gov-tree', window.parent.document).height() || 800;
        //var pkh_parent_column = $("#xxbs-list").closest('[class*="col-"]').closest('h4');
        var widget_header = $(".fpxmList");
        //resize to fit page size
        $(window).on('resize.jqGrid', function () {
            $("#xxbs-list").jqGrid('setGridWidth', widget_header.width() - 24);
        });
        $("#xxbs-list").jqGrid({
            url: '$!webPath/xxbs/qryReportData',
            datatype: "json",
            mtype: "POST",
            height: parentBodyHeight - 435,
            autowidth: true,
            colNames: ['id', '年', '月', '周', '发布日期', '报送单位', '报送人','引用次数', '附件', '操作'],
            colModel: [
                /* {name : 'rownum',width:40,
                 formatter: function (cellvalue, options, rowObject) {
                 return options.rowId;
                 }}, */
                {name: 'reportId', key: true, hidden: true},
                {name: 'reportYear', width: 40},
                {name: 'reportMonth', width: 40},
                {
                    name: 'reportWeek', width: 40
                },
                {name: 'reportDate'},
                {name: 'reportDepartment'},
                {name: 'userName'},
                {name: 'reportNum'},
                {
                    name: 'attachment',
                    formatter: function (cellvalue, options, rowObject) {
                        var html = '<a href="' + cellvalue + '">'+rowObject.fileName+'</a>'
                        return html;
                    }
                },
                {
                    name: 'myac', index: '', width: 100,
//								formatter:'actions',
                    formatter: function (cellvalue, options, rowObject) {
                        var detail = '<a onclick="updInfo(' + options.rowId + ')">编辑</a>'
                        detail = detail + '&nbsp;<a onclick="report(' + options.rowId + ')">引用</a>'
                        return detail
                    }

                }
            ],
            jsonReader: {
                root: "resultList",
                page: "page",
                total: "totalPages",
                records: "totalRecords",
                rows: "resultList"
            },
            multiselect: true,//复选框
            rowNum: 10,
            rowList: [10, 20, 50, 100],
            pager: '#xxbs-list-pager',
            viewrecords: true,
            loadComplete: function () {
                var table = this;
                setTimeout(function () {
                    styleCheckbox(table);

                    updateActionIcons(table);
                    updatePagerIcons(table);
                    enableTooltips(table);
                }, 0);

                $(table).siblings(".norecords").remove();
                var rowNum = parseInt($(table).getGridParam("records"), 10);
                if (rowNum <= 0) {
                    $(table).parent().append("<div  class=\"norecords\">没有数据...</div>");
                    $(table).siblings(".norecords").show();
                }
            }
        });
        function detailClick_pro() {
            parent.frames[0].location.href = "$!webPath/xxbs/infoAdd"
        }
        ;
        function deleteBySelectIds() {
            var ids = $("#xxbs-list").jqGrid('getGridParam', 'selarrrow');
            $.ajax({
                type: "POST",
                dataType: "Json",
                url: "$!webPath/xxbs/batchDel",
                data: {
                    ids: ids.join(',')
                },
                success: function (result) {
                    parent.frames[0].location.href = "$!webPath/xxbs/index"
                },
                error: function (data) {
                }
            });
        }
        ;
        function updInfo(id) {
            parent.frames[0].location.href = "$!webPath/xxbs/infoAdd?id=" + id;
        }
        ;
    </script>
</body>
<div id="dialog-form" title="引用">
    <form>
        <fieldset>
            <label for="reportChanel">引用单位</label><br/>
            #foreach($reportChanel in $reportChannelList)
            <input class="chanel_report chanel_$!reportChanel.channelId" id="chanel_$!reportChanel.channelId" type="checkbox" name="vehicle"
                   value="$!reportChanel.channelId"/> $!reportChanel.channelName<br/>
            #end
        </fieldset>
    </form>
</div>
<script>
    var reportId
    $("#dialog-form").dialog({
        autoOpen: false,
        height: 300,
        width: 350,
        modal: true,
        buttons: {
            "确定": function () {
                var chanelArray = []
                /* $(".chanel_report:checked").forEach(function(chanel){
                 //for (chanel in  $(".chanel_report:checked")) {
                 chanelArray.push(chanel.valuare)
                 });*/
                for(var i=0;i<$(".chanel_report:checked").length;i++){
                    chanelArray.push(parseInt($(".chanel_report:checked")[i].value));
                }
                $.ajax({
                    type: "POST",
                    dataType: "Json",
                    url: "$!webPath/xxbs/setReports",
                    data: {
                        ids: chanelArray.join(','),
                        reportId: reportId
                    },
                    success: function (result) {
                        $("#dialog-form").dialog("close");
                        parent.frames[0].location.href = "$!webPath/xxbs/index"
                    },
                    error: function (data) {
                    }
                });
            },
            "取消": function () {
                $("#dialog-form").dialog("close");
            }
        }
    });
    function report(id) {
        reportId = id
        var all =  $(".chanel_report")
        for(var i=0;i<all.length;i++){
            $(all[i]).attr("checked",false);
        }
        $("#dialog-form").dialog('open')
    }
</script>
</html>
